import Vue from 'vue'
import Router from 'vue-router'
// import store from '../store/index'
import {loginRouter} from './login/index'
import {DemoRouter} from './helloword/index'

Vue.use(Router)

export default (ctx) => {
  const router = new Router({
    mode: 'history', //去掉#
    routes: [
      {
        path: '/',
        redirect: '/demo/helloword',
        name: 'home-page'
      },
      ...DemoRouter,
      ...loginRouter
    ]
  })

  router.beforeEach((to, from, next) => {
    console.log('这里可以鉴权', process.server, ctx.$cookie.get('test'))
    next()
  })

  router.afterEach((to, from) => {
    console.log('to do something', process.server)
  })

  return router
}
